function [ r, maximum ] = error_calc( v1, v2 )

res = sum(abs((v1 - v2) / v2) / size(v1, 2));
m = max(abs(v1 / trapz(v1) - v2 / trapz(v2)));

if (nargout == 0)
    display(sprintf('error: %e, max: %e', res, m));
elseif (nargout == 1)
    r = res;
elseif (nargout == 2)
    r = res;
    maximum = m;
end

end

